<template>
    <div :key="mineKey">
        <div class="mineBox">
            <router-link :to="{path:'/index'}">
                <van-icon name="arrow-left"  style="font-size: 30px;"/>
            </router-link>
                <p @click="exit" class="setbox" >退出</p>
        </div>
        <div style="clear: both"></div>
        <mineHead class="minehead"></mineHead>
            <Minelist class="minelist"></Minelist>
        <IndexFooter class="footer"></IndexFooter>
    </div>
</template>

<script>
    import mineHead from "../components/mineHead";
    import Minelist from "../components/Minelist";
    import IndexFooter from "../components/IndexFooter";
    import {getinformain, logout,getBbs} from "../api/api";
    import {Dialog, Notify, Toast} from "vant";
    export default {
        name: "Mine",
        data(){
            return{
                mineKey:1
            }
        },
        components:{
            mineHead,Minelist,IndexFooter

        },
        methods:{
            //退出
            exit(){
                Dialog.confirm({
                    message: '确定退出？',
                })
                    .then(() => {
                        const exitUserToast = Toast.loading({
                            duration:0,
                            message: '请稍后...',
                            forbidClick: true,
                            loadingType: 'spinner',
                        });
                        // on confirm
                        logout().then(res => {
                            console.log(res.data.msg)
                            exitUserToast.clear()
                            Notify({
                                message: res.data.msg,
                                color: '#ad0000',
                                background: '#ffe1e1',
                                height:'100px'
                            });
                            this.mineKey++
                            this.$store.commit("changeLogin",{isLogin:true})
                        })
                    })
                    .catch(() => {
                        // on cancel
                    });

            },
            //    发表帖子
            upcontent(){
                console.log(111)
                getBbs(1,"家就假按揭啊",'哈哈哈哈哈哈哈哈','https://tianliang-web-vue.nos-eastchina1.126.net/bbs/Cache_566eb61750da6f58.-1369206177811922944.jpg').then(res=>{
                    console.log(res)
                    alert(res.data.msg)
                })
            }
        },
        created() {
            getinformain().then(res=>{
                console.log(res)
                if(res.data.code==0){
                    this.$store.commit("changeLogin",{isLogin:false})
                }
            })
        }

    }
</script>

<style scoped>
    .mineBox{
        position: relative;
        max-width: 729px;
        padding: 20px 10px;
        height: 200px;
        background-image:url("../assets/img/mine.jpg");
        background-repeat: no-repeat;
        opacity: 0.5;
    }
    .minehead {
        margin: -130px auto;
    }
    .minelist {
        margin-top: 120px;
    }
    .setbox {
        position: absolute;
        font-size: 20px;
        color: black;
        font-weight: bold;
        right: 20px;
        top: 6px;
        text-align: center;
    }
    .setbox>p:hover {
        color: blue;
    }


</style>